<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLivesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('lives', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->nullable();  // 创建直播平台的id
            $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
            $table->string('name')->comment('直播间名称');
            $table->dateTime('started_at')->comment('直播开始时间');
            $table->dateTime('ended_at')->comment('直播结束时间');
            $table->unsignedInteger('user_count')->default(0)->comment('直播在线人数');
            $table->string('summary')->comment('直播描述');
            $table->boolean('is_open_ask')->comment('是否开启聊天功能');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('lives');
    }
}
